<!DOCTYPE html>
<html lang="en">

<head>
    <title>泵组添加</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="../css/global.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/iconfont/iconfont.css">
    <script src="../js/vue.js"></script>
    <script src="../js/axios.js"></script>
    <link rel="stylesheet" href="../css/nutui/dist/nutui.css">
    <script src="../css/nutui/dist/nutui.js"></script>
    <link rel="stylesheet" href="../css/addPump.css">
</head>

<body>
    <div id="app">
        <div class="app_header">
            <div class="app_headerLeft" @click="back">
                <span class="iconfont icon-close-bold"></span>
            </div>
            <div class="app_headerTitle">泵组添加</div>
            <div class="app_headerRight" @click="saveBtn">
                <div class="colorBlue">保存</div>
            </div>
        </div>
        <div class="app_main">

            <div class="app_mainList" v-for="(item, index) in pumps" :key="index">
                <nut-leftslip ref='demo1'>
                    <div slot="slip-main" class="slip-main">
                        <div class="app_mainListItem">
                            <div class="app_mainListItem_label">泵组名称</div>
                            <div class="app_mainListItem_inp">
                                <input type="text" v-model="item.name" placeholder="请输入">
                            </div>
                        </div>
                        <div class="app_mainListItem">
                            <div class="app_mainListItem_label">别名</div>
                            <div class="app_mainListItem_inp">
                                <input type="text" v-model="item.alias" placeholder="请输入">
                            </div>
                        </div>
                        <div class="app_mainListItem">
                            <div class="app_mainListItem_label">参数类型</div>
                            <div class="app_mainListItem_inp" @click="show = true, pumpsId= item.id">
                                <div :style="{color:item.type=='' ?'#D1D1D1':'#000'}">{{ item.type || '请选择' }}<span class="iconfont icon-arrow-right-bold"></span></div>
                            </div>
                        </div>
                    </div>
                    <div slot="slipbtns" class="slipbtns">
                        <div class="btn">
                            <span class="iconfont icon-ashbin"></span>
                        </div>
                    </div>
                </nut-leftslip>
            </div>
            <nut-button block @click="addPumps">添加</nut-button>
        </div>
        <nut-popup v-model="show" position="bottom" round :style="{ height: '40%' }">
            <div class="popupTitle">
                <div class="left"></div>
                <div class="title">参数类型</div>
            </div>
            <div class="popupMain">
                <div class="popupMainItem" v-for="(item, index) in typeList" :key="index" @click="selectType(item)">
                    {{item.name}}</div>
            </div>
        </nut-popup>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                pumps: [
                    { id: 1, name: '', alias: '', type: 0 }
                ],
                show: false,
                pumpsId: null,
                typeList: [
                    { id: 1, name: '类型1111' },
                    { id: 2, name: '类型2222' },
                    { id: 3, name: '类型3333' },
                    { id: 4, name: '类型4444' },
                    { id: 5, name: '类型5555' },
                    { id: 6, name: '类型6666' },
                    { id: 7, name: '类型7777' },
                ]
            },
            mounted() { },
            methods: {
                delSlipItem(e) {
                    this.$refs.demo1.sliderEle.remove();
                },

                back() {
                    window.history.go(-1);
                },
                saveBtn() {
                    console.log('当前的泵组信息', this.pumps)
                },
                addPumps() {
                    let id = this.pumps.length + 1
                    this.pumps.push({ id: id, name: '', alias: '', type: '' })
                },
                selectType(data) {
                    let id = this.pumpsId
                    let list = this.pumps
                    list.map((item, index) => {
                        if (item.id == id) {
                            item.type = data.name
                        }
                    })
                    this.show = false
                }
            }
        })
    </script>
</body>

</html>